﻿import com.dmotiko.mirador.*
import com.dmotiko.general.*
import mx.transitions.*;
import mx.transitions.easing.*;
import mx.utils.Delegate;

class MiradorNuestrosSalones
extends MiradorSiteSection {
	
	public static var HOME_FRAME:Number = 2;
	public static var VIDEO_FRAME:Number = 3;
	public static var GALERIA_FRAME:Number = 4;
	public static var CAPACIDAD_FRAME:Number = 5;
	
	private var mcRoom1:MovieClip;
	private var mcRoom2:MovieClip;
	private var mcRoom3:MovieClip;
	private var nFrameSection:Number;
	private var oRoom:Object;
	
		
	function MiradorNuestrosSalones() {
		super( MiradorSite.getApp() );
		sName = MiradorSite.NUESTROS_SALONES;
		sectionChanged();
	}
		
	public function childLoaded( evnt ):Void {
		BaseClip(evnt.target).setData( oRoom );
		BaseClip(evnt.target).addEventListener( BaseClipEvent.CHANGED, Delegate.create(this, roomSelected) );
	}
	
	private function roomSelected( evnt ):Void {
		//evnt.description lo defino en el dispatchEvent de MiradorRoomButtons
		switch( evnt.target ) {
			case mcRoom1:
			MiradorSite.getApp().setContext( MiradorSite.DANBRO );
			oRoom = MiradorSite.getApp().getRooms().danbro;
			break;
			
			case mcRoom2:
			MiradorSite.getApp().setContext( MiradorSite.MIRADOR );
			oRoom = MiradorSite.getApp().getRooms().mirador;
			break;
			
			case mcRoom3:
			MiradorSite.getApp().setContext( MiradorSite.MIRADOR );
			oRoom = MiradorSite.getApp().getRooms().altos;
			break;
		}
		nFrameSection = evnt.section;
		
		registerTween("internalFadeOut", new Tween(this, "_alpha", Regular.easeOut, this._alpha, 0, 0.7, true), false, true);
	}
	
	private function tweenFinished(key:String, tween:Tween):Void {
		if ( key == "internalFadeOut") {
			this.gotoAndStop( nFrameSection );
			registerTween("internalFadeIn", new Tween(this, "_alpha", Regular.easeOut, this._alpha, 100, 0.7, true));
		} else {
			super.tweenFinished(key, tween);
		}
	}
	
}